home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 January - Disc 2
/
Macworld (1999-01) (Disk 2).dmg
/
Serious Demos
/
Symbolic Composer 4.2
/
Environment
/
Projects
/
Examples
/
More Examples
/
Converting freqs to velocities
< prev
next >
Wrap
Lisp/Scheme
|
1998-10-26
|
1KB
|
51 lines
Let's say you have frequencies 200, 330, 800, 960 and 2000 and you
want to use them to build up wave forms for velocity control.
How would you do that?
First you must convert the frequencies in ratios, this is done by
mapcaring get-ratio function with list of relative frequency values
as in below. Next these values are supplied to the gen-fourier as
frequency list parameter. See the documentation of gen-fourier for
more details of the amplitude and phase parameters.
This generates the sum frequencies 1 33/20 4 24/5 10 with
decreasing amplitudes 1 0.5 0.25 0.1 0.05 with zero phase for
all frequencies.
(setq source-vector
(gen-fourier
(mapcar #'(lambda (x) (get-ratio x :integer))
'(200/200 330/200 800/200 960/200 2000/200))
'(1 0.5 0.25 0.1 0.05)
'(0)
32))
The source-vector above is 32 elements long. You can adjust this
to match the number of elements depending how much symbols you
are playing.
To use the source-vector as velocities, lets generate 32 random symbols
with gen-random and then let the 32 values of the source vector control
the velocities of the symbols.
(def-section sect-a
default
zone '(2/1)
tonality (activate-tonality (frequency-map '(200/200 330/200 800/200 960/200 2000/200) 1 '(g# 3)))
length '(1/8)
piano
symbol (gen-random 0.5 32 '(a b c d e f g))
velocity (vector-round 0 127 source-vector)
)
(def-tempo 120)
(midiport :printer)
(play-file-p "freqtovel"
piano '(sect-a)
)